﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="ReleaseItem.aspx.cs" Inherits="JieBooLaw.WebAdmin.ReleaseItem" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <title></title>
    <ext:ResourceManager ID="ResourceManager1" runat="server" />
    <ext:XScript ID="XScript1" runat="server">

        <script type="text/javascript">
        var CompanyX = {
            _index: 0,

            getIndex: function() {
                return this._index;
            },

            setIndex: function(index) {
                if (index > -1 && index < GridPanel1.getStore().getCount()) {
                    this._index = index;
                }
            },

            getRecord: function() {
                var rec = GridPanel1.getStore().getAt(this.getIndex());  // Get the Record

                if (rec != null) {
                    return rec;
                }
            },
            
            add: function() {
                win = #{winDetails};            
                #{UserInfoTab}.getForm().reset();
                win.show();
                win.setTitle("栏目信息添加：");               
            }, 

            edit: function(index) {
                this.setIndex(index);
                this.open();
            },

            next: function() {
                this.edit(this.getIndex() + 1);
            },

            previous: function() {
                this.edit(this.getIndex() - 1);
            },
            
            open : function () {
                rec = this.getRecord();
            
                if (rec != null) {
                    win = #{winDetails};
                
                    win.show();
                    win.setTitle("栏目信息修改：" + rec.data.Account);
                
                    #{UserInfoTab}.getForm().loadRecord(rec);
                }
            }
        };
        </script>

    </ext:XScript>
</head>
<body>
    <form id="form1" runat="server">
    <ext:Toolbar ID="Toolbar1" runat="server">
        <Items>
            <ext:Button ID="btnAdd" runat="server" Text="新增" Icon="Add">
                <Listeners>
                    <Click Handler="CompanyX.add();" />
                </Listeners>
            </ext:Button>
            <ext:Button ID="btnDelete" runat="server" Text="删除" Icon="Delete">
                <DirectEvents>
                    <Click OnEvent="btnDelete_Click">
                        <EventMask ShowMask="true" Msg="Wating..." MinDelay="500" />
                        <ExtraParams>
                            <ext:Parameter Name="Values" Value="Ext.encode(#{GridPanel1}.getRowsValues({selectedOnly:true}))"
                                Mode="Raw" />
                        </ExtraParams>
                    </Click>
                </DirectEvents>
            </ext:Button>
        </Items>
    </ext:Toolbar>
    <ext:GridPanel ID="GridPanel1" runat="server" StripeRows="true" Title="栏目信息列表" AutoWidth="true"
        AutoHeight="true">
        <Store>
            <ext:Store ID="Store1" runat="server" OnRefreshData="MyData_Refresh">
                <Reader>
                    <ext:JsonReader>
                        <Fields>
                            <ext:RecordField Name="ItemID" Type="Int" />
                            <ext:RecordField Name="PItemID" Type="Int" />
                            <ext:RecordField Name="Level" Type="Int" />
                            <ext:RecordField Name="ItemName" Type="String" />
                            <ext:RecordField Name="ItemDesc" Type="String" />
                            <ext:RecordField Name="ItemSort" Type="Int" />
                            <ext:RecordField Name="LinkURL" Type="String" />
                            <ext:RecordField Name="Active" Type="Boolean" />
                        </Fields>
                    </ext:JsonReader>
                </Reader>
            </ext:Store>
        </Store>
        <ColumnModel ID="ColumnModel1" runat="server">
            <Columns>
                <ext:RowNumbererColumn />
                <ext:Column Header="" DataIndex="ItemID" Hidden="true" />
                <ext:Column Header="栏目名称" DataIndex="ItemName" />
                <ext:Column Header="描述" DataIndex="ItemDesc" />
                <ext:Column Header="图片" DataIndex="LinkURL" />
                <ext:CheckColumn Header="是否可用" DataIndex="Active" />
                <ext:CommandColumn Width="45">
                    <Commands>
                        <ext:GridCommand Icon="BugEdit" CommandName="Edit">
                            <ToolTip Text="Edit" />
                        </ext:GridCommand>
                    </Commands>
                </ext:CommandColumn>
            </Columns>
        </ColumnModel>
        <Listeners>
            <Command Handler="CompanyX.edit(rowIndex);" />
        </Listeners>
        <SelectionModel>
            <ext:CheckboxSelectionModel ID="RowSelectionModel1" runat="server" />
        </SelectionModel>
        <LoadMask ShowMask="true" />
        <BottomBar>
            <ext:PagingToolbar ID="PagingToolbar1" runat="server" PageSize="20">
                <Items>
                    <ext:Label ID="Label1" runat="server" Text="Page size:" />
                    <ext:ToolbarSpacer ID="ToolbarSpacer1" runat="server" Width="10" />
                    <ext:ComboBox ID="ComboBox1" runat="server" Width="80">
                        <Template Visible="False" ID="ctl223" EnableViewState="False" />
                        <Items>
                            <ext:ListItem Text="1" />
                            <ext:ListItem Text="2" />
                            <ext:ListItem Text="10" />
                            <ext:ListItem Text="20" />
                            <ext:ListItem Text="30" />
                            <ext:ListItem Text="50" />
                        </Items>
                        <SelectedItem Value="20" />
                        <Listeners>
                            <Select Handler="#{PagingToolbar1}.pageSize = parseInt(this.getValue()); #{PagingToolbar1}.doLoad();" />
                        </Listeners>
                    </ext:ComboBox>
                </Items>
            </ext:PagingToolbar>
        </BottomBar>
    </ext:GridPanel>
    <ext:Window ID="winDetails" runat="server" Title="Employee Details" Icon="Group"
        Width="400" Height="400" Modal="true" Hidden="true" Layout="Fit">
        <TopBar>
            <ext:Toolbar ID="Toolbar2" runat="server">
                <Items>
                    <ext:Button ID="btnPrevious" runat="server" Text="上一页" Icon="PreviousGreen">
                        <Listeners>
                            <Click Handler="CompanyX.previous();" />
                        </Listeners>
                    </ext:Button>
                    <ext:Button ID="btnNext" runat="server" Text="下一页" Icon="NextGreen">
                        <Listeners>
                            <Click Handler="CompanyX.next();" />
                        </Listeners>
                    </ext:Button>
                    <ext:Button ID="btnCancel" runat="server" Text="取消" Icon="Cancel">
                        <Listeners>
                            <Click Handler="#{winDetails}.hide();" />
                        </Listeners>
                    </ext:Button>
                    <ext:Button ID="btnSave" runat="server" Text="保存" Icon="Disk" Disabled="true">
                        <DirectEvents>
                            <Click OnEvent="btnSave_Click">
                                <EventMask ShowMask="true" Msg="Wating..." MinDelay="500" />
                            </Click>
                        </DirectEvents>
                    </ext:Button>
                </Items>
            </ext:Toolbar>
        </TopBar>
        <Items>
            <ext:TabPanel ID="TabPanel1" runat="server" Border="false">
                <Items>
                    <ext:FormPanel ID="UserInfoTab" runat="server" Title="栏目信息" Icon="User" DefaultAnchor="100%"
                        MonitorValid="true" BodyPadding="5">
                        <Items>
                            <ext:TextField ID="txtItemID" runat="server" FieldLabel="栏目编号" Disabled="true" Name="ItemID" />
                            <ext:SelectBox ID="txtPItemID" runat="server" FieldLabel="父栏目" DisplayField="ItemName"
                                ValueField="ItemID" EmptyText="请选择父栏目">
                                <Store>
                                    <ext:Store ID="Store2" runat="server">
                                        <Reader>
                                            <ext:JsonReader>
                                                <Fields>
                                                    <ext:RecordField Name="ItemID" />
                                                    <ext:RecordField Name="ItemName" />
                                                </Fields>
                                            </ext:JsonReader>
                                        </Reader>
                                    </ext:Store>
                                </Store>
                            </ext:SelectBox>
                            <ext:NumberField ID="txtLevel" runat="server" FieldLabel="级别" Name="Level" AllowBlank="false"
                                BlankText="级别不能为空！" />
                            <ext:TextField ID="txtItemName" runat="server" FieldLabel="栏目名称" Name="ItemName"
                                AllowBlank="false" BlankText="栏目名称不能为空！">
                            </ext:TextField>
                            <ext:NumberField ID="txtItemSort" runat="server" FieldLabel="排序编号" Name="ItemSort"
                                AllowBlank="false" BlankText="排序编号不能为空！" />
                            <ext:TextField ID="txtLinkURL" runat="server" FieldLabel="图片" Name="LinkURL" />
                            <ext:TextArea ID="txtItemDesc" runat="server" FieldLabel="描述" Name="ItemDesc" />
                            <ext:Checkbox ID="txtActive" runat="server" FieldLabel="是否可用" Checked="true" Name="Active" />
                        </Items>
                        <Listeners>
                            <ClientValidation Handler="#{btnSave}.setDisabled(!valid);" />
                        </Listeners>
                    </ext:FormPanel>
                </Items>
            </ext:TabPanel>
        </Items>
    </ext:Window>
    </form>
</body>
</html>
</asp:Content> 